import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import installElementPlus from './plugins/element'
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import Particles from 'particles.vue3'
import './assets/css/global.css'
import TreeTable from 'vue-table-with-tree-grid'

// import axios from 'axios'

// 配置 Axios 默认值
// axios.defaults.baseURL = 'http://localhost:8000/';

// 将 Axios 挂载到 globalThis 上
// globalThis.$http = axios;

const app = createApp(App);
app.component('TreeTable', TreeTable)
// 使用插件
app.use(router);
app.use(ElementPlus,{
  locale: zhCn,
});
app.use(Particles);

app.mount('#app');

// 节流函数
const debounce = (fn, delay) => {
  let timer = null
  return function(...args) {
    if (timer) {
      clearTimeout(timer)
      return
    }
    fn.apply(this, args)
    timer = setTimeout(() => {
      timer = null
    }, delay)
  }
}

const _ResizeObserver = window.ResizeObserver;
window.ResizeObserver = class ResizeObserver extends _ResizeObserver {
  constructor(callback) {
    const debouncedCallback = debounce(callback, 800);
    super(debouncedCallback);
  }
}